﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Security;
using System.Security.Principal;
using System.Web.Script.Serialization;

namespace Tools.Authentication
{
    public class UserInfo : IPrincipal
    {
        public string S;//systemString 
        //public int GroupId;
        //public string UserName;
        //public int role;

        // 如果还有其它的用户信息，可以继续添加。

        //public override string ToString()
        //{
        //    return string.Format("UserId: {0}, GroupId: {1}, UserName: {2}, IsAdmin: {3}, IsBussiness: {4}",
        //        UserId, GroupId, UserName, IsInRole("Admin"), IsInRole("bus"));
        //}

        #region IPrincipal Members

        [ScriptIgnore]
        public IIdentity Identity
        {
            get { throw new NotImplementedException(); }
        }

        //public bool IsInRole(int role)
        //{
        //    if (role == this.role)
        //        return true;
        //    else
        //        return false;
        //}
        public bool IsInRole(string role)
        {
            //if (string.Compare(role, "Admin", true) == 0)
            //    return GroupId == 1;
            //else if (string.Compare(role, "bus", true) == 0)
            //    return GroupId == 2;
            //else
            //    return GroupId > 0;

            return false;
        }

        #endregion
    }
}
